package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.UserCenter;
import com.example.admin.mapper.UserCenterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserCenterService {


    @Autowired
    UserCenterMapper userCenterMapper;
    public List<UserCenter> userCenterInfoPage() {

       List<UserCenter> userCenterList= userCenterMapper.userCenterInfoPage();
       return userCenterList;

    }

    public Result deleteUserById(Integer id) {

        int count=userCenterMapper.deleteUserById(id);
        if(count==0)
        {
            return Result.error("400","删除失败");
        }
        return  Result.success("删除成功");
    }

    public Result addUseInfo(UserCenter userCenter) {
          int count=  userCenterMapper.addUserInfo(userCenter);
          if(count==0)
          {
              return Result.error("400","新增失败");
          }
          return Result.success("新增成功");

    }

    public List<UserCenter> selectUserByUserName(String username) {
       List<UserCenter> userCenterList= userCenterMapper.selectUserByUserName(username);
               return userCenterList;
    }

    public Result editUserInfo(UserCenter userCenter) {
      int count=  userCenterMapper.editUserInfo(userCenter);
      if(count==0)
      {
          return Result.error("400","编辑失败");
      }
      return Result.success("编辑成功");
    }
}
